package ar.uba.dc.tl.mylanga.symbol;

public class Symbol {

	private String name;

	protected Symbol(String name) {
		assert name != null;

		this.name = name.intern();
	}

	public String getName() {
		return this.name;
	}

	@Override
	public boolean equals(Object object) {
		if (object == null) {
			return false;
		}

		if (object == this) {
			return true;
		}

		if (object.getClass() != Symbol.class) {
			return false;
		}

		Symbol other = (Symbol)object;

		return this.name == other.name;
	}

	@Override
	public int hashCode() {
		return this.getClass().hashCode() ^ this.name.hashCode();
	}

	@Override
	public String toString() {
		StringBuilder buffer = new StringBuilder("#");

		buffer.append(this.name);

		return buffer.toString();
	}
}
